//-----------------------------------------------------------------------

// <copyright file="IntegerSliderFieldDefinition.cs" company="Jamie Knight">

// Copyright (c) Jamie Knight. All rights reserved.

// </copyright>

//-----------------------------------------------------------------------

using System;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;

namespace DevKnightlie.WPF.AutoForm.FieldDefinitions
{
    public class IntegerSliderFieldDefinition: BaseFieldDefinition
    {
        #region Private Fields

        private int _minimumValue = 0;
        private int _maximumValue = 10;
        private System.Windows.Controls.Primitives.TickPlacement _tickPlacement = System.Windows.Controls.Primitives.TickPlacement.BottomRight;

        #endregion

        #region Properties

        public int MinimumValue
        {
            get { return _minimumValue; }
            set
            {
                _minimumValue = value;
            }
        }


        public int MaximumValue
        {
            get { return _maximumValue; }
            set { _maximumValue = value; }
        }


        public System.Windows.Controls.Primitives.TickPlacement TickPlacement
        {
            get { return _tickPlacement; }
            set { _tickPlacement = value; }
        }


        #endregion

        #region Methods

        public override void BuildInputControl()
        {
            Slider slider = new Slider()
            {
                Minimum = MinimumValue,
                Maximum = MaximumValue,
                TickPlacement = TickPlacement
            };
            Binding integerBinding = new Binding(PropertyName);
            BindingOperations.SetBinding(slider, RangeBase.ValueProperty, integerBinding);
            SetupEnabledBinding(slider);
            ContainerControl = InputControl = slider;
        }

        #endregion
    }
}
